package com.sky.controller.admin;

import com.sky.constant.ShopStatusConstant;
import com.sky.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author : jiang
 * @date : 2023/10/17 16:19
 */
@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {
    @Autowired
    private RedisTemplate<String, Integer> redisTemplate;

    /**
     * 设置店铺的状态
     * @param status
     * @return
     */
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status){
        redisTemplate.opsForValue().set(ShopStatusConstant.KEY,status);
        return Result.success();
    }

    /**
     * 获取店铺的状态
     * @return
     */
    @GetMapping("/status")
    public Result<Integer> getStatus(){
        Integer status = redisTemplate.opsForValue().get(ShopStatusConstant.KEY);
        return Result.success(status);
    }
}
